package Collection;

import java.util.Arrays;
import java.util.List;

public class ArrayToList {
    public static void main(String[] args) {
        String[] array ={"one","two","three","four","five"};
        System.out.println("array:"+ Arrays.toString(array));
        //asList()方法会返回内部的ArrayList，内部直接引用给定数组array
        List<String> list=Arrays.asList(array);
        System.out.println("list:"+list);
        //对集合操作后，数组也会随之改变
       array[1]="six";
        System.out.println("array:"+ Arrays.toString(array));
        System.out.println("list:"+list);
        //对数组操作后集合也会随之改变
        list.set(2,"seven");
        System.out.println("array:"+ Arrays.toString(array));
        System.out.println("list:"+list);
        //数组是定长的不会自动扩容缩容，因此不支持操作
        // list.add("1111");运行时发生不支持操作异常





    }
}
